<template>
  <div class="page">
    <el-form :model="searchForm" label-position="left" inline label-suffix="：" size="small">
      <div class="flex wap flex-start">
        <el-form-item label="操作信息">
          <el-input v-model="searchForm.loginfo" clearable></el-input>
        </el-form-item>
        <el-form-item label="操作人">
          <el-input v-model="searchForm.creator" clearable></el-input>
        </el-form-item>
        <el-form-item label="">
          <el-button type="primary" @click="getData">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <div class="flex wap flex-start" style="padding: 0px 0 10px 0">
      <!-- <el-button type="success" @click="getData">新增</el-button> -->
      <div style="width:20px"></div>
      <!-- <el-button type="danger" @click="del">删除</el-button> -->
    </div>
    <el-table :data="tableData" border style="width: 100%"  height="600"  :header-cell-style="{
        background: '#eef1f6',
        color: '#606266',
        'text-align': 'center'
      }"
      :cell-style="{ 'text-align': 'center' }">
      <el-table-column type="selection"></el-table-column>
      <!-- <el-table-column prop="logid" label="日志ID"></el-table-column> -->
      <el-table-column prop="url" label="请求url" show-overflow-tooltip></el-table-column>
      <el-table-column prop="param" label="传参信息" show-overflow-tooltip></el-table-column>
      <el-table-column prop="creator" label="操作人"></el-table-column>
      <el-table-column prop="clientip" label="ip地址"></el-table-column>
      <el-table-column prop="loginfo" label="操作信息" show-overflow-tooltip></el-table-column>
      <el-table-column prop="createtime" label="创建时间"></el-table-column>
      <!-- <el-table-column prop="" label="操作" width="120">
        <template>
          <el-button type="primary" icon="el-icon-edit" circle></el-button>
          <el-button
            type="danger"
            icon="el-icon-delete"
            circle
            @click="del"
          ></el-button>
        </template>
      </el-table-column> -->
    </el-table>
    <div style="float:right;padding:10px" v-if="total>0">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10, 20, 50, 100, 200]"
        layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { findOperLog } from "@/api/user";
export default {
  data() {
    return {
      total: 0,
      pageNum: 1,
      pageSize: 10,
      tableData: [],
      searchForm: {
        loginfo: "",
        creator: ""
      }
    };
  },
  computed: {
    queryData() {
      return {
        loginfo: this.searchForm.loginfo,
        creator: this.searchForm.creator,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      };
    }
  },
  mounted() {
    this.getData();
  },
  methods: {
    async getData() {
      const res = await findOperLog.post(this.queryData);
      if (res.resultCode === "000000") {
        this.tableData = res.data.logList;
        this.total = res.data.count ? res.data.count : 0;
      } else {
        this.$message.error(res.resultInfo);
      }
    },
    del() {
      this.$confirm("此操作将删除该项目, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    handleSizeChange(val) {
      this.pageNum = 1;
      this.pageSize = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getData();
    }
  }
};
</script>
<style lang="less" scoped></style>
